module.exports = app => {
    return class User extends app.Service {


        //out_trade_no_user 用户订单表中  新增用户订单信息
      * find_out_trade_no_user(uid) {
      //根据从微信服务器返回的openID 查询wehchat_user 用户表中 是否有该用户的信息
      const sql = `SELECT * FROM out_trade_no_user WHERE openID=? AND out_trade_no= ?`
      const result = yield app.mysql.query(sql, uid)
      return result

    }
    * update_out_trade_no_user(uid) {
      //更新
      const sql = `UPDATE out_trade_no_user SET  out_trade_no_status =? ,out_trade_no_end_time=? WHERE out_trade_no = ? `
      const result = yield app.mysql.query(sql, uid)
      return result

    }
   * update_Recharge_user(uid) {
      //更新 wechat_user 增加用户余额 和用户总充值
      const sql = `UPDATE Recharge_user SET  balance = (balance+?) ,total_consumption = (total_consumption+?) WHERE  openID =?;`
      const result = yield app.mysql.query(sql, uid)
      return result

    }
    * find_out_trade_no(uid) {
      //查找订单状态
      const sql = `SELECT * FROM out_trade_no_user WHERE out_trade_no= ?;`
      const result = yield app.mysql.query(sql, uid)
      return result

    }
    }
};